Imports MIMS.WRS.Business
Imports MIMS.WRS.Entities
Imports MyFramework

Public Class OrdersNotPlacedWithFactoryReport
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents ddlConPoint As System.Web.UI.WebControls.DropDownList
    Protected WithEvents rptList As System.Web.UI.WebControls.Repeater
    Protected WithEvents hidSupplierCode As System.Web.UI.HtmlControls.HtmlInputHidden
    Protected WithEvents btnSearch As System.Web.UI.WebControls.Button

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Protected Function GetOwnerText(ByVal data As Object) As String
        Dim officeID As Integer = Convert.ToInt32(data)
        Try
            Return OfficeService.GetOffice(officeID).OfficeName
        Catch ex As Exception
            Return "[error]"
        End Try
    End Function

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AjaxPro.Utility.RegisterTypeForAjax(GetType(MIMS_WRS.Web.AjaxUtilMethod))
        btnSearch.Attributes("onclick") = "return searchClicked();"
        If Not IsPostBack Then
            Me.ddlConPoint.DataSource = ConPointService.GetConPoints(ConPointColumns.Description, MyFramework.OrderDirection.ASC)
            Me.ddlConPoint.DataTextField = ConPointColumns.Description.ToString()
            Me.ddlConPoint.DataValueField = ConPointColumns.ConPointID.ToString()
            Me.ddlConPoint.DataBind()
            Me.ddlConPoint.Items.Insert(0, New ListItem("[All]", "-1"))

            Try
                ddlConPoint.SelectedIndex = ddlConPoint.Items.IndexOf(ddlConPoint.Items.FindByValue(RequestContext.ConPointID.ToString()))
            Catch ex As Exception
            End Try

            If RequestContext.DoReport Then
                rptList.DataSource = ShippingStatusReportService.GetOrderNotPlacedWithFactoryReport( _
                        RequestContext.CurrentUser.ActiveOfficeID, RequestContext.ReportType, RequestContext.ConPointID, RequestContext.SupplierCode)
                rptList.DataBind()
            End If
        End If
    End Sub

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Response.Redirect(String.Format("OrdersNotPlacedWithFactoryReport.aspx?rt={0}&cpid={1}&sup={2}&dorpt=1", _
                         RequestContext.ReportType, ddlConPoint.SelectedItem.Value, hidSupplierCode.Value))
    End Sub
End Class
